﻿
--提取岗位异动二级审批列表
CREATE proc [dbo].[proc_Employee_PostMove_GetApplySList_Count]
(
	@CompanyId int,
	@ename nvarchar(50),
	@audit nvarchar(4)
)
as
Begin

	Select Count(EE.Id) 
	From employee_PostMove EE Inner Join Employee E on EE.EId=E.Id
	Where
			FirstAuditPerson <> ''
		And	(@CompanyId=0 Or E.Companyid = @CompanyId)
		And E.Ename like '%'+@ename+'%'
		And ee.Proposer is not null
		And (case when ee.Secondaudit=1 then '1' 
				   when ee.Secondaudit=0 and ee.Secondauditperson is null then '0'
				   when ee.Secondaudit=0 and ee.Secondauditperson is not null then '1' end) like '%'+@audit+'%'
		And  e.state <> 5


End

RETURN
